<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
	<%-- <jsp:include page="/WEB-INF/jsp_lib/validate.jsp" /> --%>
	<link rel="stylesheet" href="${path}/style_lib/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css"></link>
 	<%-- <script type="text/javascript" src="${path}/style_lib/zTree_v3/js/jquery-1.4.4.min.js"></script> --%>
 	<script type="text/javascript" src="${path}/style_lib/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
 	<script type="text/javascript" src="${path }/style/js/chkie.js"></script>
	<script type="text/javascript">
		function zTreeOnClick(event, treeId, treeNode, clickFlag) {
		   var url = "${path}/ix/mac/manage/list.htm?bank_id="+treeNode.id;
		   $("input[name='bank_id']").val(treeNode.id);
			add_and_edit(url);
		};
		function add_and_edit(param_url){
			$.ajax({
				type:"post",
				url:param_url,
				cache:false,
				success:function(html){
					$("#add_edit_form").html(html);
				}
			});
		}
	 	var setting = {
	 			edit: {enable: false},
	 			view: {fontCss : {"margin": "2px"}},
				data: {
					simpleData: {
						enable: true,
						idKey:'_id',
						pIdKey:'super_id',
						rootPId:'root'
					}
				},
				callback: {
					onClick: zTreeOnClick
				}
			};
		var zNodes = $.parseJSON('${bankJson}');
		var zTreeObj;
		$(function(){
			$.each(zNodes,function(i,n){
				zNodes[i].iconOpen="${path}/style_lib/zTree_v3/icon/open.jpg";
				zNodes[i].iconClose="${path}/style_lib/zTree_v3/icon/close.jpg";
				zNodes[i].icon="${path}/style_lib/zTree_v3/icon/open.jpg";
				
				zNodes[i].id=zNodes[i]._id;
			
			});
			
			zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
			zTreeObj.expandAll(false);
			
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.selectNode(zTree.getNodeByParam("_id", '${bank_id}'));
			
			if(getExplorer()=="no"){
				$("#add_edit_form").attr("style","margin-left: 310px;")
			}
		});
		$(function(){
			var code =$("input[name='bank_id']").val();
			var url = "${path}/ix/mac/manage/list.htm?bank_id="+code;
			add_and_edit(url);
		});
	</script>
</head>
<body>
	<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<input name='bank_id' value='${bank_id}' type="hidden"/>
	<div class="row-fluid">
		<div style="float: left;width:300px;overflow:auto;" >
			<div class="w-box" style="width:300px;">
				<h2 style="border-bottom:solid 1px #B1E6EC;">
					<div>机构列表</div>
				</h2>
				<div class="zTreeDemoBackground left"  style="overflow:scroll;height:450px;border:solid 1px #B1E6EC;border-top-width: 0px;"> 
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
		</div>
		<div id="add_edit_form" style="float:left;margin-left: 10px;"></div>
	</div>
</body>
</html>
